package gold.digger;

import gold.utils.InputUtil;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC832 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int[][] flipAndInvertImage(int[][] A) {
            for (int[] line : A) {
                int left = 0, right = line.length - 1, temp;
                while (left <= right) {
                    temp = line[left] == 0 ? 1 : 0;
                    line[left++] = line[right] == 0 ? 1 : 0;
                    line[right--] = temp;
                }
            }

            return A;
        }
    }

    public void run() {
        Solution solution = new Solution();
        int[][] arr = InputUtil.toDoubleIntegerArray("[[1,1,0],[1,0,1],[0,0,0]]");
        System.out.println(Arrays.toString(solution.flipAndInvertImage(arr)));
    }

    public static void main(String[] args) throws Exception {
        LC832 an = new LC832();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
